<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>调查主题</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/style.css" />
<script src="__PUBLIC__/js/jquery.js" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/jquery.artDialog.js?skin=default" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/plugins/iframeTools.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function(){
        $('.add').click(function(){
             var _len = $(".option").length;
            $("#addoption").append("["+_len+"]:<input type='text' name='option["+_len+"]' class='option input-text' size='50' /><input type='hidden' name='voteid[]' /><br />")
        })
    })
</script>
<style type="text/css">
    .option{margin: 2px 0px}
</style>
</head>
<body>
<div id="main">
    <form id="login-form" action="__URL__/askedit" method="post">
        <input type="hidden" value="post" name="action" />
        <input type="hidden" value="{$classid}" name="classid" />
        <input type="hidden" value="{$info['id']}" name="fid" />
        <table width="100%" class="table_form">
            <tr><th width="80">选项名称:</th><td><input id="name" type="text" name="name" class="input-text" size="60" value="{$info['name']}" /></td></tr>
            <tr><th>单选多选:</th><td><input type="radio" value="1" name="radio" checked ="checked" /> 单选&nbsp;&nbsp;<input type="radio" value="2" name="radio"<?php if($info['radio'] == 2) echo " checked =\" checked\""?> /> 多选</td></tr>
            <tr><th align="top"><img src="__PUBLIC__/images/icon_add.gif" class="pt add" title="增加选项" /> 调查选项:</th>
                <td id="addoption">
{loop $vate $key $vo}
[{$key}]:<input type="text" name="option[{$key}]" class="option input-text" size="50" value="{$vo['name']}"/><input type="hidden" value="{$vo['id']}" name="voteid[]" /><br />
{/loop}</td></tr>  
        </table>
    </form>
</div>
    <script type="text/javascript">
        $(function () {
            var parent = art.dialog.parent,	// 父页面window对象
            api = art.dialog.open.api,//art.dialog.open扩展方法
            $ = function (id) {return document.getElementById(id)},
            form   = $('login-form'),
            name   = $('name');
            if (!api) return;
            api.title('添加/编辑')// 操作对话框
            .button({ // 自定义按钮
                name: '提交',
                callback: function () {
                    if (check(name)) form.submit();
                    return false;
                },focus: true
            },{name: '取消'});
            // 表单验证
            var check = function (input) {
                if (input.value === '') {
                    inputError(input);
                    input.focus();
                    return false;
                } else {
                    return true;
                };
            };
            // 输入错误提示
            var inputError = function (input){
                clearTimeout(inputError.timer);
                var num = 0;
                var fn = function () {
                    inputError.timer = setTimeout(function () {
                        input.className = input.className === '' ? 'login-form-error' : '';
                        if (num === 5) {
                            input.className === '';
                        } else {
                            fn(num ++);
                        };
                    }, 150);
                };
                fn();
            };
            window.onload = function () {setTimeout(function () {username.focus()}, 240);};
        })();
    </script>
</body>
</html>